Image processing device, electronic camera, and image processing program

ABSTRACT

An image processing device of the present invention includes a color-gamut determining part, a color-space determining part, and a color-space conversion part. The color-gamut determining part determines a color gamut as a range of color distribution from input image data. The color-space determining part determines a color space substantially covering the color gamut determined by the color-gamut determining part. The color-space conversion part converts the input image data into such image data that is rendered in the determined color space. The colors of the subject can thus be reproduced accurately from the converted image data.

CROSS REFERENCE TO RELATED APPLICATION

This application is a continuation application of application Ser. No.12/153,518, filed May 20, 2008, which is a continuation application ofapplication Ser. No. 10/730,057 filed Dec. 9, 2003, the disclosure ofwhich is incorporated herein by references in its entirety.

This application claims priority from Japanese Patent Application No.2002-365476, filed on Dec. 17, 2002, the entire contents of which areincorporated herein by reference.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The invention relates to an image processing device for converting colorspaces of image data. The invention also relates to an electronic cameraon which the image processing device is mounted, and an image processingprogram.

2. Description of the Related Art

In general, image data created by a color image processing device suchas an electronic camera, a digital video camera, and a scanner isinitially subjected to processings including color conversion, toneprocessing, and contour enhancement processing. The image data is thenrecorded on a recording medium such as a memory and a magnetic tape, ortransmitted to external equipment via communication media. The recordedimage data is reproduced, for example, as a photograph by a developingmachine, a printer, etc. The transmitted image data is reproduced on amonitor as a moving image or a still image, for example.

In order to reproduce the colors of the recorded or transmitted imagedata accurately, the image-capturing side and the reproduction side needto process the image data by using the same standard. For this purpose,various types of standards (color spaces) for expressing colors havebeen established. Then, the color coordinates of the three principalcolors (R, G, and B) differ from one standard to another.

FIG. 1 shows an xy chromaticity diagram showing NTSC color space andsRGB color space. Note that the horseshoe shaped area is a color rangethat humans are perceptible of (hereinafter, to be referred to asvisible region). The image-capturing side can encode only colors insidethe respective triangles with the coordinates of R, G, and B as thevertexes in the color space it uses. Similarly, the reproduction sidecan reproduce only colors inside the respective triangles with thecoordinates of R, G, and B as the vertexes in the color space it uses.In the present invention, the range of colors that can be thus expressedin a color space, as well as the range of color distribution of asubject, shall be referred to as color gamut. As is evident from FIG. 1,the ranges of colors that can be expressed in NTSC color space and sRGBcolor space are smaller than the visible region. This also holds formost other color spaces (including CIE RGB and Adobe RGB (TM)).

When the color space determined according to the color filters of animage sensor does not cover the color gamut of a subject, the colors ofthe subject is not reproducible accurately from the image data createdby this image-capturing system. Additionally, even with theimage-capturing system having a color space that covers the color gamutof a subject, it is not possible to reproduce the colors of the subjectwith accuracy if the image data created by this image-capturing systemis converted into such image data that it is rendered in a color spacenot covering the color gamut of the subject.

In view of this, Japanese Unexamined Patent Application Publication No.2002-109523 has proposed a method of establishing a new color spacecapable of expressing all colors and capturing an image in this colorspace. This new color space differs from the known color spaces in thecoordinates of the three principal colors. The image data based on thenew three principal colors is thus converted into image data based onknown three principal colors before output to an existing image outputapparatus.

In general, image data yet to be compressed consists of pixels whosecolors are encoded in a predetermined number of bits each (for example,8 bits for each of the three principal colors). If encoded in a largercolor space, the captured image data is thus expected to be greater incolor difference per tone. Once the image data is encoded in widertones, it is impossible to make the tones finer in subsequentprocessings. A greater color difference per tone results in unclearreproduced images and making it difficult to process the image data.

Besides, it is troublesome and difficult for the user to select anappropriate color space depending on the subject because he or she isrequired to have expertise on NTSC, sRGB, and other color spaces.

SUMMARY OF THE INVENTION

It is an object of the present invention to provide a technique forreproducing the color gamut of a subject with good chroma and toneswithout the necessity for the user to select a color space.

An image processing device of the present invention includes acolor-gamut determining part, a color-space determining part, and acolor-space conversion part. The color-gamut determining part determinesa color gamut as a range of color distribution from input image data.The color-space determining part determines a color space substantiallycontaining the color gamut determined by the color-gamut determiningpart. The color-space conversion part converts the input image data intoimage data which is rendered in the determined color space. It may beexpected that the colors of the subject are accurately reproducible fromthe converted image data. Incidentally, the color-space conversion partherein will sometimes be referred to as color correcting part.

According to one of the aspects of the image processing device of thepresent invention, the color-gamut determining part divides the inputimage data into a plurality of image regions, calculates a hue and achroma for each of the image regions, and determines a maximum chromafor each of the hues calculated. The color-space determining partselects a smallest color space from color spaces each having a maximumchroma equal to or higher than that of the input image data in all ofthe hues calculated by the color-gamut determining part.

This calculation function of the color-gamut determining part willsometimes be referred to as evaluation value calculation part, and eachof the divided image regions will sometimes be referred to as a smallregion. Moreover, in this aspect of the image processing device, theabove-described “a color space substantially containing the color gamut”corresponds to a color space having a maximum chroma equal to or higherthan that of the input image data in all of the hues calculated, forexample. A small color space signifies that an average of the maximumchroma determined for each of the hues is small, for example.

According to another aspect of the image processing device of thepresent invention, the color-gamut determining part maps the input imagedata onto a chromaticity diagram. Then, the color-space determining partselects a smallest color space from color spaces each containing apredetermined percentage or more of the color gamut of the input imagedata on the chromaticity diagram. Here, the color spaces each containinga predetermined percentage or more of the color gamut correspond to theabove-mentioned color space substantially containing the color gamut.Specifically, for example, it corresponds to the color space containingthe color gamut of the subject at or over a predetermined area ratio onthe chromaticity diagram. The small color space here refers to a colorspace of a small size on the chromaticity diagram, for example.

According to another aspect of the image processing device of thepresent invention, the color-space conversion part transmits informationon the color space determined by the color-space determining part to adestination to which the converted image data is output. Here, theinformation on the color space refers to several bits of digital dataindicating the name of the color space, for example.

An electronic camera of the present invention includes animage-capturing part and an image processing device. The image-capturingpart captures an optical image formed with a shooting lens to createimage data. Incidentally, this image-capturing part refers to a parthaving a release button, a CPU, a focal-plane shutter, a CCD, and asignal processing part, for example.

The image processing device includes a color-gamut determining part, acolor-space determining part, and a color-space conversion part. Thecolor-gamut determining part determines a color gamut as a range ofcolor distribution from image data obtained from the image-capturingpart. The color-space determining part determines a color spacesubstantially containing the color gamut determined by the color-gamutdetermining part. The color-space conversion part converts the inputimage data into image data which is rendered in the determined colorspace.

An image processing program of the present invention causes a computerto function as a color-gamut determining part, a color-space determiningpart, and a color-space conversion part. Here, the color-gamutdetermining part has a function of determining a color gamut as a rangeof color distribution from input image data. The color-space determiningpart has a function of determining a color space substantiallycontaining the color gamut determined by the color-gamut determiningpart. The color-space conversion part has a function of converting theinput image data into image data which is rendered in the determinedcolor space.

According to one of the aspects of the image processing program of thepresent invention, the color-gamut determining part divides the inputimage data into a plurality of image regions, calculates a hue and achroma for each of the image regions, and determines a maximum chromafor each of the calculated hues. The color-space determining partselects a smallest color space from color spaces each having a maximumchroma equal to or higher than that of the input image data in all ofthe hues calculated by the color-gamut determining part.

According to another aspect of the image processing program of thepresent invention, the color-gamut determining part maps the input imagedata onto a chromaticity diagram. Then, the color-space determining partselects a smallest color space from color spaces containing apredetermined percentage or more of the color gamut of the input imagedata on the chromaticity diagram.

According to another aspect of the image processing program of thepresent invention, the color-space conversion part transmits informationon the color space determined by the color-space determining part to adestination to which the image data converted is output.

BRIEF DESCRIPTION OF THE DRAWINGS

The nature, principle, and utility of the invention will become moreapparent from the following detailed description when read inconjunction with the accompanying drawings in which like parts aredesignated by identical reference numbers, in which

FIG. 1 is an xy chromaticity diagram showing NTSC color space and sRGBcolor space;

FIG. 2 is a block diagram of an electronic camera on which an imageprocessing device according to a first embodiment of the presentinvention is mounted;

FIG. 3 is a flowchart showing the operation of the image processingdevice of the first embodiment;

FIG. 4 is an explanatory diagram showing an example of a hue calculationtable to be used by the color-gamut determining part of FIG. 2;

FIG. 5 is an explanatory diagram showing an example of a chromacalculation table to be used by the color-gamut determining part of FIG.2;

FIG. 6 shows a way of comparing the color gamut of a subject with thecolor gamuts of respective color spaces stored in advance by thecolor-space determining part of FIG. 2;

FIG. 7 is a flowchart showing the operation of the image processingdevice of a second embodiment;

FIG. 8 is a block diagram of an electronic camera on which the imageprocessing device according to a third embodiment of the presentinvention is mounted;

FIG. 9 is a flowchart showing the operation of the image processingdevice of the third embodiment; and

FIGS. 10 (A), (B) are diagrams for illustrating the image processingdevice's processings of determining the color gamut of the subject andcomparing it with the color gamuts of respective color spaces stored inadvance according to the third embodiment.

DESCRIPTION OF THE PREFERRED EMBODIMENTS

Hereinafter, embodiments of the present invention will be described withreference to the drawings.

First Embodiment

FIG. 2 shows a first embodiment of the present invention. In thediagram, a photographing device 10A is made up of an electronic camera12A of the present invention, equipped with a shooting lens 14 and arecording medium 16. The shooting lens 14 consists of a lens group 20and an aperture (diaphragm) 22.

The electronic camera 12A includes a release button 30, a CPU 32, amemory 34, a focal-plane shutter 36, a CCD 38, a signal processing part40, a white balance adjusting part 42, a color interpolation processingpart 44 (hereinafter, to be referred to as Debayer processing part 44because it performs Debayer processing on a Bayer array as a way ofexample in the present embodiment), an image processing device 50 of thepresent invention, a gamma correction part 52, a contour enhancing part54, an image-data compressing part 56, and a recording part 58.

The CPU 32 controls each part of the electronic camera 12A.

On its light receiving plane, the CCD 38 has color filters FR, FG, andFB (not shown) transmitting the three principal colors, red, green, andblue (hereinafter, abbreviated as R, G, and B), respectively. Each pixelof the CCD 38 thus converts only the intensity of a wavelengthcorresponding to one of R, G, and B into a stored charge.

The signal processing part 40 applies clamp processing, sensitivitycorrection processing, analog-to-digital conversion, and the like to thepixel outputs of the CCD 38 to create image data. Note that the presentembodiment describes an example of the analog-to-digital conversion inwhich each of the R, G, and B pixel outputs is encoded in unit of 12bits. The signal processing part 40 inputs the created image data to theimage processing device 50 and the white balance adjusting part 42.

The white balance adjusting part 42 applies white balance processing tothe image data by using gains for white balance processing to bedescribed later as parameters. The white balance adjusting part 42inputs the processed image data to the Debayer processing part 44.

The Debayer processing part 44 applies Debayer processing to the imagedata. This provides each pixel with 12 bits of digital data on all thethree principal colors. The Debayer processing part 44 inputs theDebayer-processed image data to the image processing device 50.

The image processing device 50 includes an evaluation value calculationpart 62, a WB gain calculating part 64 (WB is short for white balance),a color-gamut determining part 66, a color-space determining part 68,and a color correcting part 70. The image processing device 50 convertsthe image data based on the color space of the three principal colors ofthe color filters on the CCD 38 into image data based on an appropriatecolor space, and inputs the same to the gamma correction part 52(details will be given later).

The gamma correction part 52 applies gamma correction to the input imagedata, and then outputs the resultant to the contour enhancing part 54.Here, for example, the gamma correction part 52 reduces the tones ofpre-converted image data in which every pixel has 12 bits for each ofthe three principal colors so that every pixel has 8 bits for each ofthe three principal colors in the processed image data. The contourenhancing part 54 applies image sharpening processing to the image data,and inputs the resultant to the image-data compressing part 56.

The image-data compressing part 56 applies, for example, JPEG conversionto the image data for compression. The recording part 58 receives, fromthe image processing device 50, color-space information indicating inwhat color space the image data input from the image-data compressingpart 56 is rendered. The recording part 58 records the image data ontothe recording medium 16 along with this color-space information.

FIG. 3 is a flowchart showing the operation of the image processingdevice 50 described above. FIG. 4 is an example of a hue calculationtable for use in the processing of the color-gamut determining part 66.FIG. 5 is an example of a chroma calculation table for use in theprocessing of the color-gamut determining part 66. FIG. 6 is anexplanatory diagram showing a way of comparing the color gamut of asubject with the color gamuts of respective color spaces stored inadvance by the color-space determining part 68. Hereinafter, theoperation of the image processing device 50 will be described in theorder of step numbers shown in FIG. 3, with reference to FIGS. 4 to 6.It should be appreciated that arithmetic expressions and numeric valuesto be seen below are given by way of example for the purpose ofreference, not limitations on the present invention.

[Step S1]

According to instructions from the CPU 32, the CCD 38 converts lightreceived from a subject through the shooting lens 14 into electriccharges for storage. According to instructions from the CPU 32, thesignal processing part 40 reads the stored charges from the CCD 38 tocreate image data. For example, the image data consists of 1000vertical×1500 horizontal, i.e., 1.5 million pixels. The image processingpart 40 inputs the created image data to the evaluation valuecalculation part 62. Note that this image data is not subjected toDebayer processing yet, and it consists of pixels each encoded in 12bits for one of the three principal colors R, G, and B.

[Step S2]

The evaluation value calculation part 62 divides the image data into 8vertical×12 horizontal, i.e., 96 regions. Hereinafter, each of thedivided regions will be referred to as small region. For each smallregion, the evaluation value calculation part 62 calculates averagesRav, Gav, and Bav of the values (expressed by digital data) thatindicate the intensities of the three principal colors R, G, and B,respectively. Specifically, the average Rav is determined by averagingthe digital data on all the pixels corresponding to R in a small region.The same operations are performed for G and B to calculate Gav and Bav.The evaluation value calculation part 62 transmits Rav, Gav, and Bav tothe color-gamut determining part 66 and the WB gain calculating part 64.The WB gain calculating part 64 determines gains for white balanceprocessing based on Rav, Gav, and Bav, and transmits the same to thewhite balance adjusting part 42.

[Step S3]

For each small region, the color-gamut determining part 66 determines arepresentative hue and a representative chroma through the followingprocedure. Initially, R/B and B/G defined by the following equations aredetermined from Rav, Gav, and Bav calculated at step S2:

R/G=Rav÷Gav×100  (1)

B/G=Bav÷Gav×100  (2)

Next, in the hue calculation table shown in FIG. 4, the datacorresponding to R/G and B/G determined is considered as arepresentative hue of the small region. In addition, in the chromacalculation table shown in FIG. 5, the data corresponding to R/G and B/Gdetermined is considered as the representative chroma of the smallregion. Note that the hue calculation table mentioned above has valuesof 0 to 255 (8 bits) on both the ordinate (B/G) and abscissa (R/G),whereas FIG. 4 shows only some representative values. The same holds forthe chroma calculation table of FIG. 5. The color-gamut determining part66 considers B/G or R/G exceeding 255 in value as 255.

[Step S4]

The color-gamut determining part 66 classifies all the small regionsaccording to the representative hues. Next, a small region having amaximum representative chroma is determined from small regions having asame value of representative hue. The representative chroma of thedetermined small region shall be the maximum chroma for therepresentative hue of this small region. In this way, the color-gamutdetermining part 66 determines the maximum chroma for each of therepresentative hues obtained at step S3. The color-gamut determiningpart 66 transmits the maximum chromas for the respective representativehues to the color-space determining part 68 as the color gamut of thesubject.

[Step S5]

As shown in FIG. 6, the color-space determining part 68 stores inadvance a relationship between representative values of hue (0, 1, . . ., 15) and maximum chromas in several color spaces (such as CIE-RGB colorspace, NTSC color space, and sRGB color space). For reference, FIG. 6also shows an example of the color gamut of a subject.

Then, the color-space determining part 68 compares the color gamut ofeach of the color spaces and that of the subject to select a smallestcolor space out of the color spaces that include the color gamut of thesubject. Specifically, the color-space determining part 68 selects acolor space having a smallest average of the maximum chroma from thecolor spaces each having a maximum chroma equal to or higher than thatof the color gamut of the subject in all the representative hues.

FIG. 6 shows an example in which NTSC color space is selected as theoptimum color space. The color-space determining part 68 transmits theinformation as to which color space has been selected (hereinafter,referred to as color-space information) to the color correcting part 70and the recording part 58. Here, the transmission is effected, forexample, by setting four bits of digital data for indicating the namesof the respective color spaces in advance and transmitting the digitaldata.

[Step S6]

The color correcting part 70 receives the image data transmitted fromthe Debayer processing part 44. Incidentally, this image data isrendered in the color space determined by the three principal colors ofthe color filters on the CCD 38. The color correcting part 70 stores inadvance therein matrix factors Ma, Mb, Mc, Md, Me, Mf, Mg, Mh, and Mifor each color space which are used for converting the transmitted imagedata into such image data that it is rendered in CIE-RGB color space,NTSC color space, sRGB color space, and the like. Note that the matrixfactors Ma to Mi are intended not only for color-space conversion butalso for color correction ascribable to the fact that neither theshooting lens 14 nor the CCD 38 has ideal spectral characteristics.

The color correcting part 70 selects matrix factors Ma to Micorresponding to the color space selected at step S5. The colorcorrecting part 70 performs color-space conversion on the transmittedimage data by using the following three equations (collectively referredto as Equation (3)):

Rm=Rc×Ma+Gc×Mb+Bc×Mc

Gm=Rc×Md+Gc×Me+Bc×Mf

Bm=Rc×Mg+Gc×Mh+Bc×Mi  (3)

In the foregoing equation, Rc, Gc, and Bc are pieces of digital datacorresponding to the three principal colors of the image datatransmitted from the Debayer processing part 44. Rm, Gm, and Bm arepieces of digital data corresponding to the three principal colors ofthe converted image data. The color correcting part 70 then transmitsthe converted image data to the gamma correction part 52.

The description so far has been made on the operation of the imageprocessing device 50 of the present embodiment. The converted image datawhich is rendered in an appropriate color space in this way is subjectedto the above-mentioned processings in the gamma correction part 52, thecontour enhancing part 54, and the image-data compressing part 56 beforerecorded onto the recording medium 16 along with the color-spaceinformation.

As described above, the image processing device 50 of the presentembodiment uses table data shown in FIGS. 4 and 5 to determinerepresentative hues and representative chromas in the respective smallregions of the image data. Then, with the maximum chromas for therepresentative hues determined as evaluation reference, the imageprocessing device 50 determines the color gamut of the subject that isexpressed by the image data based on the color space of the colorfilters on the CCD 38. Consequently, the color gamut of the subject canbe obtained efficiently with a fewer times of operations. This resultsin simplifying the configuration of the image processing device 50.Moreover, as shown in FIG. 6, whether or not the individual color spacescover the color gamut of the subject can be determined easily by simplycomparing the maximum chromas for the representative hues.

Then, the smallest color space is selected from among the color spacesthat cover the color gamut of the subject. More specifically, it ispossible to automatically select a color space that covers the colorgamut of the subject and has a minimum color difference per tone, forthe image data obtained immediately after photographing and consistingof pixels whose colors are encoded in a predetermined number of bits.This holds true even if the image data is reduced in the number of bitsby subsequent processings (gamma correction part 52).

In addition, the image data is converted into such image data that it isrendered in an appropriate color space selected, and thereafter it isrecorded onto the recording medium 16 along with this color-spaceinformation (step S6). Consequently, reproducing the image data based onthe color-space information enables the colors of the captured subjectto be reproduced accurately in favorable tones.

Moreover, the user need not have expertise on color spaces for selectinga color space so that he or she can focus on taking photographs. Also,allowing the image processing device 50 to select an appropriate colorspace depending on the color gamut of the subject makes it possible tocreate better pictures. As a result, the user's usability improvesgreatly.

The evaluation value calculation part 62 calculates the averages Rav,Gav, and Bav of R, G, and B for each small region, and transmits thecalculation results to the color-gamut determining part 66 and the WBgain calculating part 64. It is therefore possible to use thecalculation results of the evaluation value calculation part 62 both forthe processing of determining the color gamut of the subject and for thewhite balance processing. This results in simplifying the configurationof the image processings of the electronic camera 12A.

Second Embodiment

Next, description will be made on a second embodiment of the presentinvention. The present embodiment differs from the first embodiment onlyin that the calculations of the WB gain calculating part are also usedfor the processing in the color-gamut determining part (corresponding tothe part shown by the broken-lined arrow in FIG. 2). Thus, in thepresent embodiment, the image processing device shall be designateddistinctively as 50 b, the WB gain calculating part as 64 b, and thecolor-gamut determining part as 66 b while the block diagram is omitted.

FIG. 7 is a flowchart showing the operation of the image processingdevice 50 b of the present embodiment. Hereinafter, the operation of theimage processing device 50 b will be described in the order of stepnumbers shown in FIG. 7. It should be appreciated that arithmeticexpressions and numeric values to be seen below are given by way ofexample for the purpose of reference, not limitations on the presentinvention.

[Step S11]

As in step S1 of the first embodiment, image data is created and inputto the evaluation value calculation part 62.

[Step S12]

As in step S2 of the first embodiment, the evaluation value calculationpart 62 divides the image data into a plurality of small regions, anddetermines the averages Rav, Gav, and Bav of R, G; and B in each smallregion. The evaluation value calculation part 62 transmits Rav, Gav, andBav to the color-gamut determining part 66 b and the WB gain calculatingpart 64 b. The WB gain calculating part 64 b determines gains Wr, Wg,and Wb for white balance processing based on Rav, Gav, and Bav, andtransmits the same to the white balance adjusting part 42 and thecolor-gamut determining part 66 b.

[Step S13]

Based on the gains Wr, Wg, and Wb for white balance processing, thecolor-gamut determining part 66 b converts Rav, Gav, and Bav into valuesRav′, Gav′, and Bav′ that are adjusted in white balance. This conversionmethod is the same as what the white balance adjusting part 42 appliesto image data, being expressed by, e.g., the following three equations(collectively referred to as Equation (4)):

Rav′=Rav×Wr

Gav′=Gav×Wg

Bav′=Bav×Wb  (4)

As in the first embodiment, the color-gamut determining part 66 bdetermines R/G and B/G in each small region by the following equations,and determines a representative hue and a representative chroma in eachsmall region by using the hue calculation table of FIG. 4 and the chromacalculation table of FIG. 5.

R/G=Rav′÷Gav′×100  (5)

B/G=Bav′÷Gav′×100  (6)

The processing of the subsequent steps S14, S15, and S16 are the same asthat of steps S4, S5, and S6 of the first embodiment, respectively.Description thereof will thus be omitted.

As above, the second embodiment can provide the same effects as those ofthe foregoing first embodiment. Besides, in the present embodiment, thecolor-gamut determining part 66 b converts the averages Rav, Gav, andBav of R, G, and B determined for each small region into the valuesRav′, Gav′, and Bav′ that are adjusted in white balance, and thendetermines representative hues and representative chromas in therespective small regions. That is, the processing of the color-gamutdetermining part 66 b is equivalent to predicting how the image data isconverted by the white balance adjusting part 42 and determining thecolor gamut of the subject to be expressed by the image data adjusted inwhite balance. As a result, it is possible to determine the color gamutof the subject more accurately regardless of the color temperature ofthe light source that has illuminated the subject at the time ofshooting.

Third Embodiment

FIG. 8 shows a third embodiment of the present invention. The same partsas those of the first embodiment will be designated by identicalreference numbers. Description thereof will be omitted. In the diagram,a photographing device 10C is made up of an electronic camera 12C of thepresent invention, equipped with a shooting lens 14 and a recordingmedium 16.

The electronic camera 12C includes the release button 30, a CPU 32 c,the memory 34, the focal-plane shutter 36, the CCD 38, a signalprocessing part 40, an evaluation value calculation part 62C, the WBgain calculating part 64, a white balance adjusting part 42 c, theDebayer processing part 44, an image processing device 50 c of thepresent invention, the gamma correction part 52, the contour enhancingpart 54, the image-data compressing part 56, and the recording part 58.

The CPU 32 c controls each part of the electronic camera 12C.

The evaluation value calculation part 62 c is identical to theevaluation value calculation part 62 of the first embodiment except thatRav, Gav, and Bav calculated for each small region are transmitted onlyto the WB gain calculating part 64.

The white balance adjusting part 42 c is identical to the white balanceadjusting part 42 of the first embodiment except that the image dataadjusted in white balance is also input to the image processing device50 c.

The image processing device 50 c includes a color-gamut determining part66 c, a color-space determining part 68 c, and a color correcting part70. The image processing device 50 c converts image data based on thecolor space of the three principal colors of the color filters on theCCD 38 into image data based on an appropriate color space, and inputsthe same to the gamma correction part 52.

FIG. 9 is a flowchart showing the operation of the image processingdevice 50 c described above. FIGS. 10 (A), (B) are diagrams forexplaining the processing of determining the color gamut of the subjectand comparing it with the color gamuts of respective color spaces storedin advance by the image processing device 50 c. Hereinafter, theoperation of the image processing device 50 c will be described in theorder of step numbers shown in FIG. 9, with reference to FIG. 10.

[Step S31]

The signal processing part 40 reads the stored charges from the CCD 38to create image data, and inputs the same to the evaluation valuecalculation part 62 c and the white balance adjusting part 42 c. As inthe first embodiment, the evaluation value calculation part 62 c dividesthe image data into a plurality of small regions, and determines theaverages Rav, Gav, and Bav of R, G, and B, respectively, in each smallregion. Based on Rav, Gav, and Bav transmitted from the evaluation valuecalculation part 62 c, the WB gain calculating part 64 determines gainsfor white balance processing, and transmits the same to the whitebalance adjusting part 42 c. The white balance adjusting part 42 capplies white balance processing to the image data, and then inputs theresultant to the color-gamut determining part 66 c and the Debayerprocessing part 44.

[Step S32]

The color-gamut determining part 66 c maps the input image data (basedon the color space determined by the color filters on the CCD 38) ontoan xy chromaticity diagram, for example. This mapping is performed inunit of pixels, and table data is created at the same time. For example,when the image data covers three pixels that show the colorcorresponding to an x-coordinate of 0.3 and a y-coordinate of 0.4, a rowof table data is expressed as (0.3, 0.4, 3). Such table data is createdon all the coordinates within the visible region.

[Step S33]

As shown in FIG. 10(A), the color-gamut determining part 66 c dividesthe visible region on the xy chromaticity diagram into N regions basedon MacAdam ellipse, for example. Hereinafter, each of the N dividedregions will be referred to as a region of comparable colors. Thecolor-gamut determining part 66 c classifies the individual rows oftable data created at step S32 according to regions of comparablecolors. From among the regions of comparable colors, the color-gamutdetermining part 66 c selects ones that include T or more pixels of themapped image data. In FIG. 10(A), the hatched area is an example of theregions of comparable colors selected here. Note that a single regionincluding T pixels of exactly the same color can also be selected. Thecolor-gamut determining part 66 c informs the color-space determiningpart 68 c of which regions of comparable colors have been selected, asthe color gamut of the subject.

Incidentally, the value of T mentioned above may be determined accordingto the value of N and the total number of pixels of the image data sothat a difference between the actual color gamut of the subject and thecolor gamut of the subject determined by the color-gamut determiningpart 66 c falls to or below an acceptable value. The smaller the valueof T, the smaller the difference.

[Step S34]

As shown in FIG. 10(B), the color-space determining part 68 stores inadvance the ranges of distribution of several color spaces (such as NTSCcolor space and sRGB color space) on the xy chromaticity diagram. Then,the color-space determining part 68 selects the smallest color space outof the color spaces that cover the color gamut of the subject on the xychromaticity diagram. Here, a small color space refers to a color areaof a small size on the chromaticity diagram. In the example shown inFIG. 10(B), NTSC color space which covers the hatched color gamut of thesubject is selected as the optimum color space. As in the firstembodiment, the color-space determining part 68 transmits color-spaceinformation on which color space is selected to the color correctingpart 70 and the recording part 58.

If there is no color space that fully covers the color gamut of thesubject, the smallest color space is selected from among color spacesthat cover the color gamut of the subject on the xy chromaticity diagramat or above a predetermined area ratio. Here, the predetermined arearatio may be set to a value which allows the ratio of the region notcovered by the selected color space to the color gamut of the subjectdetermined by the color-gamut determining part 66 c to fall to or belowan acceptable value.

[Step S35]

As in step S6 of the first embodiment, the color correcting part 70converts the image data transmitted from the Debayer processing part 44into such image data that it is rendered in the color space selected atstep S34. The color correcting part 70 then transmits the convertedimage data to the gamma correction part 52.

The description so far has been made on the operation of the imageprocessing device 50 c of the present embodiment.

As above, the third embodiment can provide the same effects as those ofthe first and second embodiments described above.

<Supplemental Remarks on the Present Invention>

[1] The foregoing first and second embodiments have dealt with the caseswhere the image data is divided into 8 vertical×12 horizontal, i.e., 96regions. However, the present invention is not limited to suchembodiments. If the color gamut of the subject must be determined moreprecisely, the image data may be divided more finely. To put afunctional limitation, the image data should be divided at such afineness that a difference between the actual color gamut of the subjectand the color gamut of the subject determined by the image processingdevice 50 falls to or below an acceptable value (such as 1%).

[2] The first and second embodiments have dealt with the cases where theevaluation value calculation part 62 calculates, at step S2 (step S12),the averages Rav, Gav, and Bav of the three principal colors R, G, and Bfor each small region. However, the present invention is not limited tosuch embodiments. For example, values that occur with highest frequencymay be determined from the digital data on all the pixels correspondingto R in the respective small regions. The values corresponding to G andB may also be determined similarly. The values occurring with highestfrequency can be used in subsequent processing instead of the averages.Alternatively, maximum values Rmax, Gmax, and Bmax in the digital dataon all the pixels corresponding to R, G, and B in the small regions,respectively, may be determined for use instead of the averages.

[3] The third embodiment has dealt with the case where the image data ismapped onto the xy chromaticity diagram. However, the present inventionis not limited to such an embodiment. With human visual sensitivitytaken into account, for example, a uv chromaticity diagram may be usedinstead of the xy chromaticity diagram.

[4] The first to third embodiments have dealt with the cases where theimage processing device (50, 50 b, 50 c) performs color-space conversionon the image data before gamma processing. However, the presentinvention is not limited to such embodiments. Following the Debayerprocessing by the Debayer processing part 44, the gamma correction part52 may perform the gamma correction before the image data is input tothe color correcting part 70.

[5] The first to third embodiments have dealt with the cases where onecolor space is selected from among a plurality of color spaces stored inadvance. However, the present invention is not limited to suchembodiments. For example, it is possible to determine a triangle of asmallest size from triangles covering the color gamut of the subject onthe chromaticity diagram, and establish a new color space having thevertexes of the determined triangle as the color coordinates of thethree principal colors.

[6] The first to third embodiments have dealt with the cases where theimage sensor (CCD 38) has a color filter array of principal colors R, G,and B. However, the present invention is not limited to suchembodiments. For example, the present invention is also applicable to acolor filter array of complementary colors, cyan, magenta, and yellow.

[7] The first to third embodiments have dealt with the cases where theimage processing device of the present invention is used for anelectronic camera. However, the present invention is not limited to suchembodiments. For example, the image processing device of the presentinvention may be used for a scanner and the like.

[8] The processing of steps S1 to S6, steps S11 to S16, or steps S31 toS35 described above may be coded into an image processing program. Inthis case, the same effects as those of the first to third embodimentscan be obtained if the image processing program is used as part of theCPU of an electronic camera, for example.

The invention is not limited to the above embodiments and variousmodifications may be made without departing from the spirit and scope ofthe invention. Any improvement may be made in part or all of thecomponents.

1. An image processing device comprising: a color-gamut determining partfor determining a color gamut as a range of color distribution frominput image data input from an input part; a color-space determiningpart for determining a color space substantially containing the colorgamut determined by said color-gamut determining part; and a color-spaceconversion part for converting the input image data into image datawhich is rendered in the determined color space and for transmitting aconverted image data and information on the color space determined bysaid color-space determining part as information corresponding to theconverted image data.
 2. The image processing device according to claim1, wherein: said color-gamut determining part divides the input imagedata into a plurality of image regions and calculates a hue and a chromafor each of the image regions to determine a maximum chroma for each ofhues calculated; and said color-space determining part selects asmallest color space from color spaces each having a maximum chromaequal to or higher than that of the input image data in all of the huescalculated by said color-gamut determining part.
 3. The image processingdevice according to claim 1, wherein: said color-gamut determining partmaps the input image data onto a chromaticity diagram; and saidcolor-space determining part selects a smallest color space from colorspaces each containing a predetermined percentage or more of the colorgamut of the input image data on said chromaticity diagram.
 4. Anelectronic camera comprising: an image-capturing part for capturing anoptical image formed with a shooting lens to create image data; and theimage processing device according to claim 1, for determining a range ofcolor distribution of the created image data to determine a color space,and converting the created image data into image data which is renderedin the determined color space.
 5. A computer readable recording mediumrecording a image processing program for causing a computer to functionas said color-gamut determining part, said color-space determining part,and said color-space conversion part according to claim
 1. 6. A computerreadable recording medium recording a image processing program forcausing a computer to function as said color-gamut determining part,said color-space determining part, and said color-space conversion partaccording to claim
 2. 7. A computer readable recording medium recordinga image processing program for causing a computer to function as saidcolor-gamut determining part, said color-space determining part, andsaid color-space conversion part according to claim
 3. 8. The electroniccamera according to claim 4, wherein said color-space conversion partperforms a color correction of imaging condition when converting theinput image data into image data which is rendered in the determinedcolor space.